import BasicUse from './lib/basic-use'

import ZPageCard from './lib/page-card'
import ZSwitchOneZero from './lib/switch-one-zero'
import { ZSelectUser, ZSelectUnit, ZUserPicker, ZUnitPicker } from './lib/select-unit-user'
import ZUserUnitRoleAuthority from './lib/authority'
import ZSelectRole from './lib/select-role'
import ZSelectApplication from './lib/select-application'
import ZFileUploader from './lib/file-uploader'
import VImgPreview from './lib/VImgPreview'
import ZImageUploader from './lib/image-uploader'
import ZUnitGroup from './lib/unit-group'
import ZSelectDicCode from './lib/select-dic-code'
import ZSelectDicList from './lib/select-dic-list'
import { ZAppIcon, ZIconShow } from './lib/app-icon'
import { ZEmail, ZPhone, ZMoney, ZIdcard, ZInput, ZTextarea } from './lib/input'
import ZDialog from './lib/dialog'
import ZOperateButton from './lib/operate'
import ZTableOperation from './lib/table-operation'
import { ZAddButton, ZSearchButton, ZResetButton, ZExportButton, ZImportButton, ZLinkButton, ZBatchDeleteButton, ZBackButton, ZOkButton, ZCancelButton, ZClearButton } from './lib/buttons'
// 条件弹窗
import ZConditionDialog from './lib/dialog-condition'
import Submitter from './lib/submitter'
import ZDescription from './lib/description'

import ZTextfileReader from './lib/textfile-upload'

import ZHelper from './lib/helper'

import ZRouteView from './lib/route-view'

import ZColorPicker from './lib/color-picker'

import './lib/styles/index.less'

// 应用和表单图标
import './lib/app-icon/iconfont/app/iconfont.css'
import './lib/app-icon/iconfont/form/iconfont.css'

// 组件集合，用于遍历
const components = [
  ZSwitchOneZero, ZEmail, ZSelectUser, ZSelectUnit, ZConditionDialog,
  ZSelectRole, ZUserUnitRoleAuthority, ZUnitGroup, ZPhone, ZMoney, ZIdcard, ZInput, ZTextarea,
  ZFileUploader, VImgPreview, ZAppIcon, ZIconShow, ZImageUploader, ZSelectDicCode, ZSelectDicList, ZSelectApplication, ZOperateButton,
  ZAddButton, ZSearchButton, ZResetButton, ZExportButton, ZImportButton, ZLinkButton, ZBatchDeleteButton, ZBackButton, ZOkButton, Submitter,
  ZCancelButton, ZClearButton, ZDescription, ZRouteView, ZUserPicker, ZUnitPicker, ZTextfileReader, ZTableOperation,
  ZColorPicker
]

// 定义 install 方法
const install = function (Vue, router, store) {
  if (install.installed) {
    return
  }
  Vue.use(BasicUse)
  // 注册全局Dialog组件
  Vue.use(ZDialog, router, store)

  // 注册全局帮助组件
  Vue.use(ZHelper, router, store)
  // 遍历注册全局组件
  components.map((component) => Vue.component(component.name, component))

  install.installed = true
}

export {
  ZPageCard, ZSwitchOneZero, ZEmail, ZSelectUser, ZSelectUnit,
  ZSelectRole, ZUserUnitRoleAuthority, ZUnitGroup, ZPhone, ZMoney, ZIdcard, ZInput, ZTextarea,
  ZFileUploader, VImgPreview, ZAppIcon, ZIconShow, ZImageUploader, ZSelectDicCode, ZSelectDicList, ZSelectApplication,
  ZOperateButton, ZAddButton, ZSearchButton, ZResetButton, ZExportButton, ZImportButton, ZLinkButton, ZBatchDeleteButton,
  ZBackButton, ZOkButton, ZCancelButton, ZClearButton, ZConditionDialog, ZDescription, ZRouteView, Submitter,
  ZUserPicker, ZUnitPicker, ZHelper, ZTableOperation, ZColorPicker
}

export default {
  // 导出的对象必须具备一个 install 方法
  install
}
